import { _decorator, Component, Node, Vec3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('followPlayer')
export class followPlayer extends Component {
    @property(Node) player
    interval: Vec3 = new Vec3(0, 0, 0)
    start() {
        this.interval.set(this.node.position.x - this.player.position.x, this.node.position.y - this.player.position.y, this.node.position.z - this.player.position.z)
    }

    update(deltaTime: number) {
        this.node.setPosition(this.player.position.x + this.interval.x, this.player.position.y + this.interval.y, this.player.position.z + this.interval.z)
    }
}


